package com.android.util;


import android.graphics.Bitmap;
import android.graphics.Point;

public class OpenCVHelper {
    static {
        System.loadLibrary("opencv");
    }

    public static Point[][] cannyImg(Bitmap srcBitmap, Bitmap resultBitmap) {
        if (srcBitmap == null) {
            return null;
        }
        int w = srcBitmap.getWidth();
        int h = srcBitmap.getHeight();
        try {
            return canny(srcBitmap, resultBitmap, w, h, 80, 200, 0/*CV_RETR_EXTERNAL*/, 1/*CV_CHAIN_APPROX_NONE*/);
        } catch (UnsatisfiedLinkError error) {
            return null;
        }
    }

    public static native void inpaint(Object src, Object inpaintMask, Object result, int w, int h, double inpaintRadius, int flags);

    public static native Point[][] canny(Object src, Object result, int w, int h, double threshold1, double threshold2,
                                         int mode, int method);

    public static native void setAllPoint(Object[] allPoint);

    public static native void clearAllPoint();

    public static native Point[] findNeighbor(int x, int y, int threshold);

    public static native Point edgeAdjust(int x, int y, int strokeWidth, int adsorbDistance, int nearbyEdge);
}
